package com.chinacache.maint.workorder.entity;

import java.util.LinkedHashSet;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.OrderBy;
import javax.persistence.Table;

import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import org.hibernate.annotations.GenericGenerator;
import org.hibernate.annotations.Parameter;

import com.chinacache.maint.commons.entity.BaseEntity;

@Entity
@Table(name = "WO_FIELD_ATTRIBUTE")
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
public class FieldAttribute extends BaseEntity {
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private Integer id;
	private String value;
	private String name;
	private Field field;
	private Integer type;
	private Integer isMustInput;
	private String memo;
	private Integer groupId;
	private Integer checkBoxLink;
	private Set<FlowFieldAttribute> flowFieldAttributes = new LinkedHashSet<FlowFieldAttribute>(
			0);

	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "fieldAttribute")
	@OrderBy("id")
	public Set<FlowFieldAttribute> getFlowFieldAttributes() {
		return flowFieldAttributes;
	}

	public void setFlowFieldAttributes(
			Set<FlowFieldAttribute> flowFieldAttributes) {
		this.flowFieldAttributes = flowFieldAttributes;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "FIELD_ID")
	public Field getField() {
		return field;
	}

	public void setField(Field field) {
		this.field = field;
	}

	@Column(name = "NAME")
	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	@Id
	@Column(name = "FIELD_ATTRIBUTE_ID")
	@GeneratedValue(generator = "SEQ_RPT_USER_TO_CLASS")
	@GenericGenerator(name = "SEQ_RPT_USER_TO_CLASS", strategy = "seqhilo", parameters = { @Parameter(name = "sequence", value = "SEQ_RPT_USER_TO_CLASS") })
	public Integer getId() {
		return id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	@Column(name = "VALUE")
	public String getValue() {
		return value;
	}

	public void setValue(String value) {
		this.value = value;
	}

	@Column(name = "TYPE")
	public Integer getType() {
		return type;
	}

	public void setType(Integer type) {
		this.type = type;
	}
	
	@Column(name = "IS_MUST_INPUT")
	public Integer getIsMustInput() {
		return isMustInput;
	}

	public void setIsMustInput(Integer isMustInput) {
		this.isMustInput = isMustInput;
	}

	@Column(name = "MEMO")
	public String getMemo() {
		return memo;
	}

	public void setMemo(String memo) {
		this.memo = memo;
	}

	@Column(name = "GROUPID")
	public Integer getGroupId() {
		return groupId;
	}

	public void setGroupId(Integer groupId) {
		this.groupId = groupId;
	}

	@Column(name = "CHECKBOXLINK")
	public Integer getCheckBoxLink() {
		return checkBoxLink;
	}

	public void setCheckBoxLink(Integer checkBoxLink) {
		this.checkBoxLink = checkBoxLink;
	}
}
